import 'dart:async';

import 'package:get/get.dart';

import 'connect_to_device_dialog_state.dart';

class ConnectToDeviceDialogLogic extends GetxController {
  final ConnectToDeviceDialogState state = ConnectToDeviceDialogState();
  Timer? myTimer;

  @override
  void onReady() {
    super.onReady();

    myTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
      state.leaveTime--;
      if (state.leaveTime == 0) {
        timer.cancel();
        Get.back();
      }
    });
  }

  @override
  void onClose() {
    // TODO: implement onClose
    super.onClose();
    myTimer?.cancel();
    myTimer = null;
  }
}
